<script setup lang="ts">
const route = useRoute();
const groupId = Array.isArray(route.params.groupId)
  ? route.params.groupId.join('/')
  : route.params.groupId!;
const contentTypePath = stringifyContentTypePath('group', groupId);
const mainContent = await useMainContent<MainContentGroup>(contentTypePath);

const { showNewsAside, showContentContributionsAside } = useAsideMinor();
if (ERUDIT.config.contributors?.enabled) {
  showContentContributionsAside(
    mainContent.contentRelativePath,
    mainContent.type,
    undefined,
    mainContent.contributions,
  );
} else {
  showNewsAside();
}

const phrase = await usePhrases('group', 'begin_learning');
const lastChangedDate = useLastChanged(() => mainContent.lastmod);

await useContentSeo({
  title: mainContent.title,
  bookTitle: mainContent.bookTitle,
  description: mainContent.description,
  contentTypeSuffix: phrase.group,
  contentTypePath: {
    type: 'group',
    contentId: mainContent.shortId,
  },
  seo: mainContent.seo,
  breadcrumbs: mainContent.breadcrumbs,
  lastmod: mainContent.lastmod,
  children: mainContent.children,
  contributions: mainContent.contributions,
  flags: mainContent.flags,
  connections: mainContent.connections,
});
</script>

<template>
  <MainGlow />
  <MainSectionPreamble>
    <MainDecoration
      role="preamble-float"
      :decoration="mainContent.decoration"
    />
    <MainBreadcrumbs :breadcrumbs="mainContent.breadcrumbs" />
    <MainDecoration
      role="preamble-static"
      :decoration="mainContent.decoration"
    />
    <MainTitle
      icon="folder-open"
      :title="mainContent.title"
      :contentLabel="phrase.group"
    />
    <MainFlags :flags="mainContent.flags" />
    <MainDescription :description="mainContent.description" />
    <MainConnections :connections="mainContent.connections" />
    <MainContentStats
      mode="single"
      :stats="mainContent.stats"
      :lastChangedDate
    />
    <div class="h-main-half"></div>
    <MainAction
      v-if="mainContent.children[0]"
      icon="rocket"
      :label="formatText(phrase.begin_learning)"
      :link="mainContent.children[0].link"
    />
    <div class="h-main-half"></div>
    <MainStickyHeader :mainContent :lastChangedDate />
  </MainSectionPreamble>
  <MainContentChildren :children="mainContent.children" />
  <MainSection>
    <AdsBannerBottom v-if="adsBottomAllowed()" />
  </MainSection>
</template>
